Skip to content

Refactor and modernize Exporter package:#2

Merged
santwer merged 8 commits intomasterfrom
v0.5
Mar 21, 2026
Merged

Refactor and modernize Exporter package:#2
santwer merged 8 commits intomasterfrom
v0.5

Conversation

@santwer
Copy link
Owner

@santwer santwer commented Feb 3, 2026

  • Introduce PDFConversionException with tests to handle PDF conversion errors.
  • Implement TemplatePathResolver service for smarter file path resolution with related tests.
  • Enhance type annotations across Exporter and processor classes, aligning with modern PHP standards.
  • Update Exporter methods with consistent return types and input validation.
  • Fix typos (e.g., cloneRecrusiveBlockscloneRecursiveBlocks, implementsMinumumimplementsMinimum).
  • Add symfony/process dependency for external process interactions.
  • Extend tests across processors, exceptions, and services for improved coverage.

Note

Medium Risk
Medium risk because it changes core export processing (XML escaping, block cloning helpers, temp file handling) and replaces PDF conversion execution with symfony/process, which can affect runtime behavior across environments.

Overview
Modernizes the package for newer platforms by raising requirements to PHP 8.3+/Laravel 10+, upgrading phpoffice/phpword, and adding symfony/process for external command execution.

Hardens and refactors the export pipeline: introduces TemplatePathResolver for consistent template path resolution, rewrites PDFExporter to run LibreOffice via Process and throw PDFConversionException, and tightens typing/strict-types across processors (Exporter, ExportHelper, GlobalVariables, etc.) including disabling PHPWord output escaping in favor of the package’s own escaping.

Renames legacy typos like cloneRecrusiveBlocks/arrayListRecusive while keeping deprecated aliases, expands PHPUnit coverage for exporters/processors/services, and adds CI + MkDocs documentation build/deploy (ReadTheDocs + optional GitHub Pages) with a shortened README pointing to the new docs.

Written by Cursor Bugbot for commit bce9c2f. This will update automatically on new commits. Configure here.

- Introduce `PDFConversionException` with tests to handle PDF conversion errors.
- Implement `TemplatePathResolver` service for smarter file path resolution with related tests.
- Enhance type annotations across `Exporter` and processor classes, aligning with modern PHP standards.
- Update `Exporter` methods with consistent return types and input validation.
- Fix typos (e.g., `cloneRecrusiveBlocks` → `cloneRecursiveBlocks`, `implementsMinumum` → `implementsMinimum`).
- Add `symfony/process` dependency for external process interactions.
- Extend tests across processors, exceptions, and services for improved coverage.
- Introduce comprehensive guides on features such as charts, tables, checkboxes, images, and batch processing.
- Provide step-by-step usage instructions, including a quick start.
- Highlight deprecated features and recommend migrating to export classes.
- Include detailed configuration and architectural insights.
- Add `mkdocs.yml` for structured documentation navigation.
- Document automatic XML escaping for text values and introduce a dedicated [XML Escaping & Security](xml-escaping.md) guide.
- Update `TemplateProcessor::replace()` to handle UTF-8, prevent double-escaping, and support `allowTags` for preserving trusted inline formatting.
- Disable PHPWord's internal output escaping to avoid redundancy.
- Extend unit tests to validate escaping, UTF-8 preservation, null handling, and special character encoding.
- Update documentation for clarity on new functionality and security best practices.
- Add strict typing with `declare(strict_types=1)` across all classes for better type enforcement.
- Update property types and annotations for clarity and consistency.
- Replace legacy switch-case with `match()` in exporter logic for improved readability.
- Refactor `cloneRecursiveBlocks` and related methods for type safety and better parameter handling.
- Introduce helper methods like `filterVariableReplacements` for better code organization.
- Transition classes like `Writer`, `PDFExporter`, and `GlobalVariables` to `final` for immutability.
- Apply quality-of-life improvements, including null coalescing assignments (`??=`), consistent spacing, and code deduplication.
- Add GitHub Actions CI workflow for PHPUnit tests and MkDocs builds.
- Upgrade `mkdocs.yml` to use Material theme with enhanced navigation, accessibility, and styling features.
- Define documentation requirements in `docs/requirements.txt`.
- Include `.readthedocs.yaml` for Read the Docs configuration.
- Document optional GitHub Pages deployment details in `README.md`.
- Add `.gitignore` for ignoring build artifacts and vendor files.
- Extend `wordexport.stub` with a `values` method for consistency.
- Add default `phpunit.xml.dist` for standardized testing configuration.
…ling:

- Replace `tempnam()` usage with `createUniqueTempFile()` to avoid PHP deprecations.
- Simplify and modernize `tempDir()` directory creation logic.
- Add recursion for directory creation with proper checks and error handling.
- Update related methods for consistent usage of `createUniqueTempFile()`.
@santwer santwer marked this pull request as ready for review March 21, 2026 09:28
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

…ce provider:

- Optimize `WordTemplateExporter` by reusing formatted data within loops for improved performance.
- Remove unused methods and interfaces from `ExporterProvider`, simplifying the class structure.
@cursor
Copy link

cursor bot commented Mar 21, 2026

You have used all of your free Bugbot PR reviews.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@santwer santwer merged commit 1911bd7 into master Mar 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant